/**
 * 员工的接口
 */
import request from "@/utils/request";

/**
 * 获取员工简单列表
 */
const getEmployeeSimple = () => request({
  url: '/sys/user/simple'
})

/**
 * 获取员工列表
 */
const getEmployeeList = params => request({
  url: '/sys/user',
  params
})

/**
 * 获取员工个人信息
 */
const getPersonalDetail = id => request({
  url: `/employees/${id}/personalInfo`
})

/**
 * 更新用户详情的基础信息
 */
const updatePersonal = data => request({
  url: `/employees/${data.userId}/personalInfo`,
  method: 'PUT',
  data
})

/**
 * 获取员工岗位信息
 */
const getJobDetail = id => request({
  url: `/employees/${id}/jobs`
})

/**
 * 保存岗位信息
 */
const updateJob = data => request({
  url: `/employees/${data.userId}/jobs`,
  method: 'PUT',
  data
})

/**
 * 删除员工接口
 */
const delEmployee = id => request({
  url: `/sys/user/${id}`,
  method: 'DELETE'
})

/**
 * 新增员工接口
 */
const addEmployee = data => request({
  url: `/sys/user`,
  method: 'POST',
  data
})

/**
 * 批量导入员工
 */
const importEmployee = data => request({
  url: '/sys/user/batch',
  method: 'POST',
  data
})

/**
 * 保存员工基本信息
 */
const saveUserDetailById = data => request({
  url: `/sys/user/${data.id}`,
  method: 'PUT',
  data
})

/**
 * 给员工分配角色
 */
const assignRoles = data => request({
  url: '/sys/user/assignRoles',
  method: 'PUT',
  data
})

export {
  getEmployeeSimple,
  getEmployeeList,
  updatePersonal,
  getPersonalDetail,
  getJobDetail,
  delEmployee,
  addEmployee,
  importEmployee,
  saveUserDetailById,
  updateJob,
  assignRoles
}